use HerdingData1.dta,clear

*Table 1 Summary statistics
** Panel A Descriptive statistc
logout,save(Table_1_Panel_A) word replace: ///
tabstat FHM  DFVisit FCount NFund IOwn QRet  ///
 SGr Lev BM Size QTurn QVar ROE , stat(n mean sd p25 median p75) ///
 columns(statistics) format (%9.3f) 
 
 
** Panel B Differences in firm characteristics between firms visited and firms not
logout,save (Table_1_Panel_B) word replace: ///
tabstat FHM FBHM FSHM IOwn QRet  SGr Lev BM Size QTurn QVar  ROE, by(DFVisit) ///
 format (%9.3f)   
ttest FHM,by(DFVisit)
ttest FBHM,by(DFVisit)
ttest FSHM,by(DFVisit)
ttest IOwn,by(DFVisit)
ttest QRet,by(DFVisit)
ttest SGr,by(DFVisit)
ttest Lev,by(DFVisit)
ttest BM,by(DFVisit)
ttest Size,by(DFVisit)
ttest QTurn,by(DFVisit)
ttest QVar,by(DFVisit)
ttest ROE,by(DFVisit)


**Table 2 Baseline regression results
global Controls HM IOwn QRet SGr Lev BM LnSize QTurn QVar ROE  
reghdfe  FHM DFVisit , absorb(IndID  Season StockID) vce(robust)
estimates store m1
reghdfe FHM LnFC , absorb(IndID  Season StockID) vce(robust)
estimates store m2
reghdfe FHM LnNF , absorb(IndID  Season StockID) vce(robust)
estimates store m3
reghdfe FHM DFVisit $Controls, absorb(IndID  Season StockID) vce(robust)
estimates store m4
reghdfe FHM  LnFC $Controls, absorb(IndID  Season StockID) vce(robust)
estimates store m5
reghdfe FHM LnNF $Controls, absorb(IndID  Season StockID) vce(robust)
estimates store m6
esttab m1 m2 m3 m4 m5 m6 using Baseline.rtf, replace compress nogap star(* 0.1 ** 0.05 *** 0.01) ///
scalar(N r2_a F)  t(%9.3f)  b(%9.3f)  


**Table 3 Instrumental variable and 2SLS regressions
ivregress 2sls FHM $Controls i.IndID i.Season ( LnFC  =Travel),r first  
ereturn list

ivregress 2sls FHM  $Controls  i.IndID i.Season (LnNF =Travel),r first
ereturn list


***Table A1 Alternative thresholds on mutual fund trades
reghdfe FHM DFVisit  $Controls    if NoIns5==1, absorb(IndID  Season StockID) vce(robust) 
estimates store m1
reghdfe FHM LnFC  $Controls   if NoIns5==1,  absorb(IndID  Season StockID) vce(robust) 
estimates store m2
reghdfe FHM LnNF $Controls   if NoIns5==1,  absorb(IndID  Season StockID) vce(robust)
estimates store m3


reghdfe FHM DFVisit  $Controls    if NoIns10==1,  absorb(IndID  Season StockID) vce(robust)
estimates store m4
reghdfe FHM LnFC  $Controls    if NoIns10==1,  absorb(IndID  Season StockID) vce(robust)
estimates store m5
reghdfe FHM LnNF  $Controls    if NoIns10==1,  absorb(IndID  Season StockID) vce(robust)
estimates store m6


esttab m1 m2 m3 m4 m5 m6 using TableA1.rtf,ar2 replace compress nogap star(* 0.1 ** 0.05 *** 0.01) ///
scalar(N r2_a F)  t(%9.3f)   b(%9.3f)  

 
**Table A2 Alternative herding measure
use HerdingData2.dta,clear
 
global Controls HM2 IOwn QRet SGr Lev BM LnSize QTurn QVar ROE
reghdfe FHM2 DFVisit  $Controls  ,  absorb(IndID  Season StockID) vce(robust)
estimates store m1
reghdfe FHM2  LnFC  $Controls  ,  absorb(IndID  Season StockID) vce(robust)
estimates store m2
reghdfe FHM2 LnNF $Controls  ,  absorb(IndID  Season StockID) vce(robust)
estimates store m3

reghdfe FHM2 DFVisit  $Controls   if NoIns5==1,  absorb(IndID  Season StockID) vce(robust)
estimates store m4
reghdfe FHM2  LnFC  $Controls     if NoIns5==1,  absorb(IndID  Season StockID) vce(robust)
estimates store m5
reghdfe FHM2 LnNF $Controls    if NoIns5==1,  absorb(IndID  Season StockID) vce(robust)
estimates store m6

reghdfe FHM2 DFVisit  $Controls    if NoIns10==1,  absorb(IndID  Season StockID) vce(robust) 
estimates store m7
reghdfe FHM2 LnFC  $Controls    if NoIns10==1,  absorb(IndID  Season StockID) vce(robust)
estimates store m8
reghdfe FHM2 LnNF  $Controls    if NoIns10==1,  absorb(IndID  Season StockID) vce(robust)
estimates store m9

esttab m1 m2 m3 m4 m5 m6 m7 m8 m9 using TableA2.rtf,replace compress nogap star(* 0.1 ** 0.05 *** 0.01) ///
scalar(N r2_a F)  t(%9.3f)  b(%9.3f)  
 

**Table 4 Columns (1) to (2)
use HerdingData4.dta,clear
reghdfe FVHM LnFC HM  IOwn QRet SGr Lev BM LnSize QTurn QVar ROE, absorb(Season StockID IndID) vce(robust)
estimates store m1
reghdfe FVHM LnNF HM IOwn  QRet SGr Lev BM LnSize QTurn QVar ROE, absorb(Season StockID IndID) vce(robust)
estimates store m2
esttab   m1 m2 using Table4Columns1_2.rtf,ar2 replace compress nogap star(* 0.1 ** 0.05 *** 0.01) ///
scalar(N r2_a F)  t(%9.3f) b(%9.3f)  

****Table 4 Columns (3) to (7)
use HerdingData5.dta,clear
keep  FNVHM DFVisit LnFC LnNF HM IOwn  QRet SGr Lev BM LnSize QTurn QVar ROE IndID   StockID Season
reghdfe FNVHM LnFC  HM IOwn  QRet SGr Lev BM LnSize QTurn QVar ROE if DFVisit==1, absorb(IndID   StockID Season) vce(robust)
estimates store m3
reghdfe FNVHM  LnNF HM IOwn  QRet SGr Lev BM LnSize QTurn  QVar ROE    if DFVisit==1, absorb(IndID   StockID Season) vce(robust)
estimates store m4
reghdfe FNVHM DFVisit HM  IOwn  QRet SGr Lev BM LnSize QTurn  QVar ROE   , absorb(IndID   StockID Season) vce(robust)   
estimates store m5
reghdfe FNVHM  LnFC HM IOwn  QRet SGr Lev BM LnSize QTurn  QVar ROE  , absorb(IndID   StockID Season) vce(robust)  
estimates store m6
reghdfe FNVHM  LnNF HM IOwn  QRet SGr Lev BM LnSize QTurn  QVar ROE  , absorb(IndID   StockID Season) vce(robust)  
estimates store m7
esttab   m3 m4 m5 m6 m7 using Table4Columns3_7.rtf,ar2 replace compress nogap star(* 0.1 ** 0.05 *** 0.01) ///
scalar(N r2_a F)  t(%9.3f) b(%9.3f)  


use HerdingData3.dta,clear
**Table 5 The impact of information asymmetry
*Panel A.Information asymmetry proxied by analyst coverage

xtset StockID Season
egen MAn=median(Analyst)
gen DAan=0
replace DAan=1 if Analyst>=MAn
gen Int1=DFVisit*DAan
gen Int2=LnFC*DAan
gen Int3=LnNF*DAan

reghdfe FHM DFVisit DAan Int1 HM IOwn  QRet SGr Lev BM LnSize  QTurn VAR  ROE,  absorb(IndID   StockID Season) vce(robust)
estimates store m1
reghdfe FHM LnFC DAan Int2 HM IOwn  QRet SGr Lev BM LnSize  QTurn VAR ROE,  absorb(IndID  StockID Season) vce(robust)
estimates store m2
reghdfe FHM LnNF DAan Int3 HM IOwn   QRet SGr Lev BM LnSize  QTurn VAR  ROE,  absorb(IndID   StockID Season) vce(robust)
estimates store m3

esttab m1 m2 m3  using Table5PanelA.rtf,ar2 replace compress nogap star(* 0.1 ** 0.05 *** 0.01) ///
scalar(N r2_a F)  t(%9.3f)   b(%9.3f)  

*2.Panel B Information asymmetry proxied by stock illiqudity

xtset StockID Season
egen MLL=median(ILL)
gen DILL=0
replace DILL=1 if ILL>=MLL
gen Int4=DILL*DFVisit
gen Int5=DILL*LnFC
gen Int6=DILL*LnNF

reghdfe FHM DFVisit DILL Int4 HM IOwn  QRet SGr Lev BM LnSize  QTurn VAR  ROE,  absorb(IndID   StockID Season) vce(robust)
estimates store m1
reghdfe FHM LnFC DILL Int5 HM IOwn  QRet SGr Lev BM LnSize  QTurn VAR ROE,  absorb(IndID   StockID Season) vce(robust)
estimates store m2
reghdfe FHM LnNF DILL Int6 IOwn HM  QRet SGr Lev BM LnSize  QTurn VAR  ROE,  absorb(IndID   StockID Season) vce(robust)
estimates store m3

esttab m1 m2 m3  using Table5PanelB.rtf,ar2 replace compress nogap star(* 0.1 ** 0.05 *** 0.01) ///
scalar(N r2_a F)  t(%9.3f)   b(%9.3f)  

**
** Table A3

use  HerdingData6.dta,clear

reg FNVTrade VTrade NVTrade ,r
estimates store m1
reg FNVTrade VTrade NVTrade i.IndID  i.HalfYear,r
estimates store m2
reg FNVTrade  VTrade NVTrade  HRet HBM HSize ,r
estimates store m3
reg FNVTrade VTrade NVTrade    HRet HBM HSize  i.IndID  i.HalfYear,r
estimates store m4
esttab m1 m2 m3 m4 using TableA3.rtf,ar2 replace compress nogap star(* 0.1 ** 0.05 *** 0.01) ///
scalar(N r2_a F)  t(%9.3f) b(%9.3f) indicate("Industry FE=*.IndID" "Halfyear FE=*.HalfYear")

 